/**
 * 布局样式
 * 定义页面布局、容器、栅格系统等样式
 */

/* ========== 容器 ========== */

.container {
    width: 100%;
    margin: 0 auto;
    padding: 0 var(--spacing-4);
}

@media (min-width: 640px) {
    .container {
        max-width: var(--container-sm);
    }
}

@media (min-width: 768px) {
    .container {
        max-width: var(--container-md);
    }
}

@media (min-width: 1024px) {
    .container {
        max-width: var(--container-lg);
    }
}

@media (min-width: 1280px) {
    .container {
        max-width: var(--container-xl);
    }
}

@media (min-width: 1536px) {
    .container {
        max-width: var(--container-2xl);
    }
}

.container-fluid {
    width: 100%;
    margin: 0 auto;
    padding: 0 var(--spacing-4);
}

.container-sm {
    max-width: var(--container-sm);
    margin: 0 auto;
    padding: 0 var(--spacing-4);
}

.container-md {
    max-width: var(--container-md);
    margin: 0 auto;
    padding: 0 var(--spacing-4);
}

.container-lg {
    max-width: var(--container-lg);
    margin: 0 auto;
    padding: 0 var(--spacing-4);
}

.container-xl {
    max-width: var(--container-xl);
    margin: 0 auto;
    padding: 0 var(--spacing-4);
}

/* ========== 栅格系统 ========== */

.row {
    display: flex;
    flex-wrap: wrap;
    margin: 0 calc(var(--spacing-4) * -0.5);
}

.row-no-gutters {
    margin: 0;
}

.col {
    flex: 1 0 0%;
    padding: 0 calc(var(--spacing-4) * 0.5);
}

.row-no-gutters .col {
    padding: 0;
}

/* 列尺寸 */
.col-1 { flex: 0 0 8.333333%; max-width: 8.333333%; }
.col-2 { flex: 0 0 16.666667%; max-width: 16.666667%; }
.col-3 { flex: 0 0 25%; max-width: 25%; }
.col-4 { flex: 0 0 33.333333%; max-width: 33.333333%; }
.col-5 { flex: 0 0 41.666667%; max-width: 41.666667%; }
.col-6 { flex: 0 0 50%; max-width: 50%; }
.col-7 { flex: 0 0 58.333333%; max-width: 58.333333%; }
.col-8 { flex: 0 0 66.666667%; max-width: 66.666667%; }
.col-9 { flex: 0 0 75%; max-width: 75%; }
.col-10 { flex: 0 0 83.333333%; max-width: 83.333333%; }
.col-11 { flex: 0 0 91.666667%; max-width: 91.666667%; }
.col-12 { flex: 0 0 100%; max-width: 100%; }

/* 响应式栅格 */
@media (min-width: 640px) {
    .col-sm-1 { flex: 0 0 8.333333%; max-width: 8.333333%; }
    .col-sm-2 { flex: 0 0 16.666667%; max-width: 16.666667%; }
    .col-sm-3 { flex: 0 0 25%; max-width: 25%; }
    .col-sm-4 { flex: 0 0 33.333333%; max-width: 33.333333%; }
    .col-sm-5 { flex: 0 0 41.666667%; max-width: 41.666667%; }
    .col-sm-6 { flex: 0 0 50%; max-width: 50%; }
    .col-sm-7 { flex: 0 0 58.333333%; max-width: 58.333333%; }
    .col-sm-8 { flex: 0 0 66.666667%; max-width: 66.666667%; }
    .col-sm-9 { flex: 0 0 75%; max-width: 75%; }
    .col-sm-10 { flex: 0 0 83.333333%; max-width: 83.333333%; }
    .col-sm-11 { flex: 0 0 91.666667%; max-width: 91.666667%; }
    .col-sm-12 { flex: 0 0 100%; max-width: 100%; }
}

@media (min-width: 768px) {
    .col-md-1 { flex: 0 0 8.333333%; max-width: 8.333333%; }
    .col-md-2 { flex: 0 0 16.666667%; max-width: 16.666667%; }
    .col-md-3 { flex: 0 0 25%; max-width: 25%; }
    .col-md-4 { flex: 0 0 33.333333%; max-width: 33.333333%; }
    .col-md-5 { flex: 0 0 41.666667%; max-width: 41.666667%; }
    .col-md-6 { flex: 0 0 50%; max-width: 50%; }
    .col-md-7 { flex: 0 0 58.333333%; max-width: 58.333333%; }
    .col-md-8 { flex: 0 0 66.666667%; max-width: 66.666667%; }
    .col-md-9 { flex: 0 0 75%; max-width: 75%; }
    .col-md-10 { flex: 0 0 83.333333%; max-width: 83.333333%; }
    .col-md-11 { flex: 0 0 91.666667%; max-width: 91.666667%; }
    .col-md-12 { flex: 0 0 100%; max-width: 100%; }
}

@media (min-width: 1024px) {
    .col-lg-1 { flex: 0 0 8.333333%; max-width: 8.333333%; }
    .col-lg-2 { flex: 0 0 16.666667%; max-width: 16.666667%; }
    .col-lg-3 { flex: 0 0 25%; max-width: 25%; }
    .col-lg-4 { flex: 0 0 33.333333%; max-width: 33.333333%; }
    .col-lg-5 { flex: 0 0 41.666667%; max-width: 41.666667%; }
    .col-lg-6 { flex: 0 0 50%; max-width: 50%; }
    .col-lg-7 { flex: 0 0 58.333333%; max-width: 58.333333%; }
    .col-lg-8 { flex: 0 0 66.666667%; max-width: 66.666667%; }
    .col-lg-9 { flex: 0 0 75%; max-width: 75%; }
    .col-lg-10 { flex: 0 0 83.333333%; max-width: 83.333333%; }
    .col-lg-11 { flex: 0 0 91.666667%; max-width: 91.666667%; }
    .col-lg-12 { flex: 0 0 100%; max-width: 100%; }
}

@media (min-width: 1280px) {
    .col-xl-1 { flex: 0 0 8.333333%; max-width: 8.333333%; }
    .col-xl-2 { flex: 0 0 16.666667%; max-width: 16.666667%; }
    .col-xl-3 { flex: 0 0 25%; max-width: 25%; }
    .col-xl-4 { flex: 0 0 33.333333%; max-width: 33.333333%; }
    .col-xl-5 { flex: 0 0 41.666667%; max-width: 41.666667%; }
    .col-xl-6 { flex: 0 0 50%; max-width: 50%; }
    .col-xl-7 { flex: 0 0 58.333333%; max-width: 58.333333%; }
    .col-xl-8 { flex: 0 0 66.666667%; max-width: 66.666667%; }
    .col-xl-9 { flex: 0 0 75%; max-width: 75%; }
    .col-xl-10 { flex: 0 0 83.333333%; max-width: 83.333333%; }
    .col-xl-11 { flex: 0 0 91.666667%; max-width: 91.666667%; }
    .col-xl-12 { flex: 0 0 100%; max-width: 100%; }
}

/* ========== 页面布局 ========== */

.page {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.page-header {
    background-color: var(--color-bg-primary);
    border-bottom: 1px solid var(--color-border-primary);
    position: sticky;
    top: 0;
    z-index: var(--z-40);
}

.page-content {
    flex: 1;
    padding: var(--spacing-6) 0;
}

.page-footer {
    background-color: var(--color-bg-secondary);
    border-top: 1px solid var(--color-border-primary);
    padding: var(--spacing-6) 0;
    margin-top: auto;
}

/* ========== 侧边栏布局 ========== */

.sidebar-layout {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: 250px;
    background-color: var(--color-bg-secondary);
    border-right: 1px solid var(--color-border-primary);
    transition: all var(--transition-normal) var(--ease-in-out);
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
    z-index: var(--z-30);
}

.sidebar-collapsed {
    width: 60px;
}

.sidebar-content {
    padding: var(--spacing-4);
}

.main-content {
    flex: 1;
    padding: var(--spacing-6);
    overflow-y: auto;
}

/* 响应式侧边栏 */
@media (max-width: 768px) {
    .sidebar-layout {
        flex-direction: column;
    }

    .sidebar {
        width: 100%;
        height: auto;
        position: relative;
    }

    .sidebar-collapsed {
        width: 100%;
    }

    .main-content {
        padding: var(--spacing-4);
    }
}

/* ========== 头部布局 ========== */

.header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--spacing-4) var(--spacing-6);
    min-height: 64px;
}

.header-brand {
    display: flex;
    align-items: center;
    gap: var(--spacing-3);
}

.header-logo {
    height: 32px;
    width: auto;
}

.header-title {
    font-size: var(--font-size-lg);
    font-weight: var(--font-weight-semibold);
    color: var(--color-text-primary);
}

.header-nav {
    display: flex;
    align-items: center;
    gap: var(--spacing-4);
}

.header-actions {
    display: flex;
    align-items: center;
    gap: var(--spacing-3);
}

/* ========== 导航栏 ========== */

.nav {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-1);
}

.nav-item {
    display: flex;
    align-items: center;
    gap: var(--spacing-3);
    padding: var(--spacing-3) var(--spacing-4);
    border-radius: var(--radius);
    color: var(--color-text-secondary);
    text-decoration: none;
    transition: all var(--transition-fast) var(--ease-in-out);
    font-size: var(--font-size-base);
    font-weight: var(--font-weight-medium);
}

.nav-item:hover {
    background-color: var(--color-bg-tertiary);
    color: var(--color-text-primary);
}

.nav-item.active {
    background-color: var(--color-primary-light);
    color: var(--color-primary);
}

.nav-icon {
    width: var(--size-icon);
    height: var(--size-icon);
    display: flex;
    align-items: center;
    justify-content: center;
}

.nav-text {
    flex: 1;
}

.nav-badge {
    background-color: var(--color-error);
    color: var(--color-text-inverse);
    font-size: var(--font-size-xs);
    padding: var(--spacing-1) var(--spacing-2);
    border-radius: var(--radius-full);
    min-width: 20px;
    text-align: center;
}

/* 水平导航 */
.nav-horizontal {
    flex-direction: row;
    gap: var(--spacing-2);
}

.nav-horizontal .nav-item {
    padding: var(--spacing-2) var(--spacing-4);
}

/* ========== 标签页 ========== */

.tabs {
    display: flex;
    border-bottom: 1px solid var(--color-border-primary);
    gap: var(--spacing-1);
}

.tab {
    padding: var(--spacing-3) var(--spacing-6);
    border-bottom: 2px solid transparent;
    color: var(--color-text-secondary);
    text-decoration: none;
    font-weight: var(--font-weight-medium);
    transition: all var(--transition-fast) var(--ease-in-out);
    cursor: pointer;
    border: none;
    background: none;
    font-size: var(--font-size-base);
}

.tab:hover {
    color: var(--color-text-primary);
    background-color: var(--color-bg-secondary);
}

.tab.active {
    color: var(--color-primary);
    border-bottom-color: var(--color-primary);
    background-color: transparent;
}

.tab:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.tab-content {
    padding: var(--spacing-6);
}

.tab-pane {
    display: none;
}

.tab-pane.active {
    display: block;
}

/* ========== 内容区域 ========== */

.content-section {
    margin-bottom: var(--spacing-8);
}

.content-header {
    margin-bottom: var(--spacing-6);
}

.content-title {
    font-size: var(--font-size-2xl);
    font-weight: var(--font-weight-bold);
    color: var(--color-text-primary);
    margin: 0 0 var(--spacing-2) 0;
}

.content-subtitle {
    font-size: var(--font-size-lg);
    color: var(--color-text-secondary);
    margin: 0;
}

.content-body {
    line-height: var(--line-height-relaxed);
    color: var(--color-text-secondary);
}

.content-actions {
    display: flex;
    align-items: center;
    gap: var(--spacing-3);
    margin-top: var(--spacing-6);
}

/* ========== 空状态 ========== */

.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: var(--spacing-12);
    text-align: center;
}

.empty-state-icon {
    width: 64px;
    height: 64px;
    margin-bottom: var(--spacing-4);
    color: var(--color-text-tertiary);
}

.empty-state-title {
    font-size: var(--font-size-lg);
    font-weight: var(--font-weight-semibold);
    color: var(--color-text-primary);
    margin: 0 0 var(--spacing-2) 0;
}

.empty-state-description {
    color: var(--color-text-secondary);
    margin: 0 0 var(--spacing-6) 0;
}

.empty-state-actions {
    display: flex;
    align-items: center;
    gap: var(--spacing-3);
}

/* ========== 页面过渡 ========== */

.page-transition {
    animation: pageFadeIn var(--transition-normal) var(--ease-in-out);
}

@keyframes pageFadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ========== 滚动条样式 ========== */

.custom-scrollbar::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

.custom-scrollbar::-webkit-scrollbar-track {
    background: var(--color-bg-secondary);
    border-radius: var(--radius-full);
}

.custom-scrollbar::-webkit-scrollbar-thumb {
    background: var(--color-border-secondary);
    border-radius: var(--radius-full);
}

.custom-scrollbar::-webkit-scrollbar-thumb:hover {
    background: var(--color-border-primary);
}

/* ========== 响应式工具类 ========== */

/* 显示/隐藏 */
@media (max-width: 639px) {
    .hidden-xs { display: none !important; }
    .block-xs { display: block !important; }
}

@media (min-width: 640px) and (max-width: 767px) {
    .hidden-sm { display: none !important; }
    .block-sm { display: block !important; }
}

@media (min-width: 768px) and (max-width: 1023px) {
    .hidden-md { display: none !important; }
    .block-md { display: block !important; }
}

@media (min-width: 1024px) and (max-width: 1279px) {
    .hidden-lg { display: none !important; }
    .block-lg { display: block !important; }
}

@media (min-width: 1280px) {
    .hidden-xl { display: none !important; }
    .block-xl { display: block !important; }
}

/* ========== 工具类 ========== */

.overflow-x-auto { overflow-x: auto; }
.overflow-y-auto { overflow-y: auto; }
.overflow-x-hidden { overflow-x: hidden; }
.overflow-y-hidden { overflow-y: hidden; }

.flex-nowrap { flex-wrap: nowrap; }
.flex-wrap { flex-wrap: wrap; }
.flex-wrap-reverse { flex-wrap: wrap-reverse; }

.flex-grow-0 { flex-grow: 0; }
.flex-grow-1 { flex-grow: 1; }
.flex-shrink-0 { flex-shrink: 0; }
.flex-shrink-1 { flex-shrink: 1; }

.justify-start { justify-content: flex-start; }
.justify-end { justify-content: flex-end; }
.justify-center { justify-content: center; }
.justify-between { justify-content: space-between; }
.justify-around { justify-content: space-around; }
.justify-evenly { justify-content: space-evenly; }

.items-start { align-items: flex-start; }
.items-end { align-items: flex-end; }
.items-center { align-items: center; }
.items-baseline { align-items: baseline; }
.items-stretch { align-items: stretch; }

.self-start { align-self: flex-start; }
.self-end { align-self: flex-end; }
.self-center { align-self: center; }
.self-stretch { align-self: stretch; }